package aufgabe4;

public class MatrixPruefung
{
  public static boolean pruefeMatrix(int[][] matrix)
  {
    int[] rowSums = new int[matrix.length];
    int[] collumnSums = new int[matrix[0].length];
    for(int i = 0; i<matrix.length; i++)
      for(int j = 0; j<matrix[i].length; j++)
      {
        rowSums[i] += matrix[i][j];
        collumnSums[j] += matrix[i][j];
      }
    int sum = rowSums[0];
    for(int i = 0; i<rowSums.length; i++)
      if(rowSums[i] != sum)
        return false;
    for(int i = 0; i<collumnSums.length; i++)
      if(collumnSums[i] != sum)
        return false;
    return true;
  }
  
  public static void main(String[] args)
  {
    int[][] matrix = {{2,2,3}, {2,2,2}, {2,2,2}};
    System.out.println(pruefeMatrix(matrix));
  }
}
